package org.jeecg.modules.fund.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.fund.entity.FundHold;
import org.jeecg.modules.fund.entity.FundHoldGroup;
import org.jeecg.modules.fund.entity.FundLibrary;
import org.jeecg.modules.fund.mapper.FundHoldMapper;
import org.jeecg.modules.fund.service.IFundHoldGroupService;
import org.jeecg.modules.fund.service.IFundHoldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "持有分组管理")
@RequestMapping("/sys/fund/hold/group")
@Slf4j
public class FundHoldGroupController {
    @Autowired
    private IFundHoldGroupService fundHoldGroupService;

    /**
     * 分组列表
     * @param req
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<List<FundHoldGroup>> queryPageList(HttpServletRequest req) {
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<FundHoldGroup> holdGroupList = fundHoldGroupService.list(new LambdaQueryWrapper<FundHoldGroup>()
                .eq(FundHoldGroup::getUserId,sysUser.getId())
                .orderByDesc(FundHoldGroup::getSort));
        return Result.OK(holdGroupList);
    }
}
